package xujun.control.outlookpanel;

import xujun.control.XHeader;
import xujun.control.XListSplitListener;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;

/**
 * @author 徐骏
 * @data 2010-7-2
 */
public class XOutlookSplitListener extends XListSplitListener {
    public XOutlookSplitListener(XHeader header) {
        super(header);
    }

    public void mouseDragged(MouseEvent e) {
        if (!header.isShrinked() && lastPoint != null) {
            JComponent parent = (JComponent) header.getParent();
            Dimension size = parent.getPreferredSize();
            Point thisPoint = e.getPoint();
            int xMovement = thisPoint.x - lastPoint.x;
            size.width += xMovement;
            size.width = Math.max(size.width, 37);
            parent.setPreferredSize(size);
            header.revalidateParent();
        }
    }
}
